<template>
  <ve-radar :data="chartData" :extend="extend" :settings="chartSettings"></ve-radar>
</template>

<script>
import {
  mapActions,
  mapGetters
} from 'vuex'
import {
  selectProresult
} from '@/network/home'
export default {
  props: ["userId"],
  data() {
    this.chartSettings = {
        labelMap: {
          A: 'A 理智我',
          B: 'B 组织我',
          C: 'C 感觉我',
          D: 'D 实验我'
        },
        areaStyle: {
            opacity: 0.7
        }
    },
    this.extend = {
      //样式
      textStyle: {
        color: '#000'
      }
    }
    return {
      chartData: {
        // columns: ['全脑优势', '得分'],
        columns: [
            "得分","A","B","C","D"
        ],
        rows: [
            // { '全脑优势': 'A 理智我', '得分': 0 },
            // { '全脑优势': 'B 组织我', '得分': 0 },
            // { '全脑优势': 'C 感觉我', '得分': 0 },
            // { '全脑优势': 'D 实验我', '得分': 0 },
            {"得分":"最低","A":0,"B":0,"C":0,"D":0},
            {"得分":"最高","A":8,"B":8,"C":8,"D":8},
            {"得分":"你的得分","A":0,"B":0,"C":0,"D":0}
        ],
      }
    }
  },
  computed: {
    ...mapGetters([
      'userinfo'
    ]),
  },
  created() {
    this.selectproresult()
  },
  methods: {
    ...mapActions([
      'selectProresult'
    ]),
    selectproresult() {
      let params = {
        user_Id: this.userId,
        questionType_Id: 20
      }
      selectProresult(params)
          .then((data) => {
            // console.log(data.data[0])
            this.chartData.rows[2].A = JSON.parse(data.data[0].countScore).A
            this.chartData.rows[2].B = JSON.parse(data.data[0].countScore).B
            this.chartData.rows[2].C = JSON.parse(data.data[0].countScore).C
            this.chartData.rows[2].D = JSON.parse(data.data[0].countScore).D
            this.$emit('resultStrengthHBDI',data.data[0].resultStrength);
          })
          .catch((err) => {
            // this.$toast(err.msg, 'error')
          })
      }
  }
}
</script>
